<template>
  <div
    class="user-info"
    v-show="showInfo"
    :style="{ top: (mousePosition.y / 2) + 'px', left: (mousePosition.x + 15) + 'px' }"
  >
    <div class="top">
      <dl>
        <dt>{{ userData.name }}
          <icon-svg :icon-name="userData.sex ? 'man' : 'woman'"></icon-svg>
        </dt>
        <dd>微信号: {{ userData.id }}</dd>
      </dl>
      <div class="block">
        <el-avatar
          shape="square"
          :size="59"
          :src="$utils.getAvatar(userData.avatar)"
        ></el-avatar>
      </div>
    </div>
    <div class="btm">
      <div class="region">
        <div class="region-key">地区</div>
        <div class="region-val">
          <template v-for="region in ['country', 'province', 'district']">
            <span
              v-if="userData[region]"
              :key="region"
            >{{ userData[region] }}&nbsp;&nbsp;&nbsp;</span>
          </template>
        </div>
      </div>
      <ul class="info-tools">
        <li
          class="send-msg"
          @click="handleInfoTools(1)"
        ></li>
        <li
          class="share"
          @click="handleInfoTools(0)"
        ></li>
      </ul>
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'

@Component
export default class UserInfoModal extends Vue {
  @Prop({ default: false }) public showInfo!: boolean
  @Prop({ required: true }) public userData!: object
  @Prop({ required: true, default: { x: 0, y: 0 } }) public mousePosition!: object
  public handleInfoTools(type: number) {}
}
</script>

<style lang="scss" scoped>
.user-info {
  width: 336px;
  height: 267px;
  background-color: #fff;
  position: absolute;
  z-index: 100;
  left: 0;
  top: 0;
  box-shadow: $shadow;
  border-radius: 8px;
  padding: 0 43px;
  font-size: 14px;
  text-align: left;
  .top,
  .btm {
    height: 50%;
  }
  .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid $border;
    dt {
      font-size: 22px;
      color: $key-text;
      line-height: 1;
      padding-bottom: 10px;
    }
    dd {
      color: $value-text;
    }
  }
  .btm {
    .region {
      padding: 34px 0 25px;
      .region-key,
      .region-val {
        display: inline-block;
        vertical-align: top;
      }
      .region-key {
        letter-spacing: 17px;
        color: $value-text;
      }
      .region-val {
        color: $key-text;
      }
    }
    .info-tools {
      width: 100%;
      height: 30px;
      padding: 2px 0;
      li {
        height: 30px;
        width: 30px;
        float: right;
        background: url('~assets/images/wechat.png') no-repeat;
        background-position: 0 100%;
        background-size: 150px;
        cursor: pointer;
        &.share {
          background-position-x: 5px;
        }
        &.send-msg {
          background-position-x: -29px;
          margin-left: 36px;
        }
      }
    }
  }
}
</style>
